/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.loja.view.component.aggregation.factory;

import br.com.loja.model.service.exception.ServiceException;
import br.com.loja.view.component.aggregation.EntityToMany;
import br.com.loja.view.component.aggregation.EnumToMany;
import br.com.loja.view.component.factory.ComponentFactory;
import java.awt.Component;

/**
 *
 * @author DavidLuiz
 */
public class AggregationToManyFactory extends ComponentFactory {

    public AggregationToManyFactory(Class<?> classType) {
        super(classType);
    }

    @Override
    public Component getComponent() {

        if (isEnum()) {
            return new EnumToMany(getClassType());
        }

        try {
            return new EntityToMany(getClassType());
        } catch (ServiceException ex) {
            //IMPLEMENTAR LOG
            System.err.println(ex.getMessage());
            ex.printStackTrace();
        }

        return null;
    }

}
